package org.ggn.init;

import java.io.File;
import java.util.Set;

import org.ggn.dao.GradeDao;
import org.ggn.model.Course;
import org.ggn.model.Grade;
import org.ggn.util.DirFinalValue;
import org.ggn.util.HibernateUtil;
import org.hibernate.Session;

public class MakeDir {

	/**
	 * 这个方法实现在硬盘上创建各个科目的文件夹，而不用手动创建
	 * @param args
	 */
	public static void main(String[] args) {

		Session session = null;
		Grade u = null;
		try {
			session = HibernateUtil.openSession();
			Set<Course> set = null;
			for (int i = 1; i <= 3; i++) {
				u = (Grade) session.load(Grade.class, i);
				set = u.getCourses();
				for (Course course : set) {
					String path1= DirFinalValue.rootpath + "\\"
							+ course.getGrade().getName() + "\\"
							+ course.getShortname()+DirFinalValue.exam_iofo;
					String path2 = DirFinalValue.rootpath + "\\"
							+ course.getGrade().getName() + "\\"
							+ course.getShortname()+DirFinalValue.pager_year_an;
					String path3 = DirFinalValue.rootpath + "\\"
							+ course.getGrade().getName() + "\\"
							+ course.getShortname()+DirFinalValue.pager_year_no;
					System.out.println(path1);
					System.out.println(path2);
					System.out.println(path3);
					File file1 = new File(path1);
					file1.mkdirs();
					File file2 = new File(path2);
					file2.mkdirs();
					File file3 = new File(path3);
					file3.mkdirs();
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			HibernateUtil.close(session);
		}
	}
}
